﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;

namespace LCTNote.Models.ViewModels
{
    class ThuMucViewModel : Model
    {
        public int ma { get; set; }
        public string tenThuMuc { get; set; }
        public int maThuMucCha { get; set; }
        public int maNguoiTao { get; set; }
        public string moTaThuMuc { get; set; }

        public override void assignModel(SqlDataReader dataReader)
        {
            for (int i = 0; i < dataReader.FieldCount; i++)
            {
                switch (dataReader.GetName(i))
                {
                    case "Ma":
                        ma = !dataReader.IsDBNull(i) ? dataReader.GetInt32(i) : 0; break;
                    case "TenThuMuc":
                        tenThuMuc = !dataReader.IsDBNull(i) ? dataReader.GetString(i) : null; break;
                    case "MaThuMucCha":
                        maThuMucCha = !dataReader.IsDBNull(i) ? dataReader.GetInt32(i) : 0; break;
                    case "MaNguoiTao":
                        maNguoiTao = !dataReader.IsDBNull(i) ? dataReader.GetInt32(i) : 0; break;
                    case "MoTaThuMuc":
                        moTaThuMuc = !dataReader.IsDBNull(i) ? dataReader.GetString(i) : null; break;
                    default:
                        break;
                }
            }
        }
    }
}
